
package com.catsic.zcjc.specifiction;

import com.catsic.base.specification.BaseSpec;
import com.catsic.base.specification.QueryWraper;
import com.catsic.zcjc.condition.EquipMaintainCondition;
import com.catsic.zcjc.entity.EquipMaintain;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.criteria.Path;
import java.util.List;

public class EquipMaintainSpec extends BaseSpec<EquipMaintain> {

	public EquipMaintainSpec(EquipMaintainCondition condition){
		super(condition);
	}
	

	@Override
	protected void addCondition(QueryWraper<EquipMaintain> queryWraper) {
		EquipMaintainCondition condition = (EquipMaintainCondition) getCondition();
		/**
		 * 多表联查
		 */
		String equipId = condition.getEquipId();
		if(StringUtils.isNotBlank(equipId)){
			Path<EquipMaintain> equip = queryWraper.getRoot().get("equip");
			addEqualCondition(queryWraper, equip.get("id"),equipId);
		}

	
		/**
		 * 自定义排序
		 */
		queryWraper.addOrder(queryWraper.getCb().asc(queryWraper.getRoot().get("maintainTime")));
	    
		
	}
}
